<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>订单操作</title>
<link rel="stylesheet" href="../js/framework/jquery-ui/css/ui-lightness/jquery-ui-1.10.2.custom.css">
<link rel="stylesheet" href="../style/personnel/order.css">
<script type="text/javascript" src="../js/framework/jquery/jquery.js"></script>
<script type="text/javascript" src="../js/framework/jquery-ui/js/jquery-ui-1.10.2.custom.js"></script>
<script type="text/javascript" src="../js/framework/knockoutjs/knockout-2.2.1.js"></script>
<script type="text/javascript" src="../js/framework/knockoutjs/knockout.mapping-latest.debug.js"></script>
<script type="text/javascript" src="../js/personnel/orderenabled.js"></script>
<script type="text/javascript" src="../js/personnel/orderflow.js"></script>
<script type="text/javascript" src="../js/personnel/orderuncancled.js"></script>
<script type="text/javascript" src="../js/util/objectUtil.js"></script>
</head>
<body class="order-body">
<div id="order-tabs">
	<ul>
		<li><a href="#tabs-enabled">确认订单</a></li>
		<li><a href="#tabs-workflow">订单流程处理</a></li>
		<li><a href="#tabs-uncancled">恢复作废的订单</a></li>
		<li><a href="dishcreate.html">菜式操作</a></li>
	</ul>
	<div id="tabs-enabled">
		<form data-bind="submit: getOrderById">
			订单号:<input type="text" data-bind="value: orderId"/>
			<input type="submit" value="获取订单" />
		</form>
		<input type="button" value="自动获取新订单" data-bind="event:{click: getAutoOrder}">
		<hr />
		<span data-bind="text: orderStatus"></span><br />
		<input type="button" value="作废订单" data-bind="event:{click: cancledOrder}" />
		<input type="button" value="提交订单" data-bind="event:{click: enabledOrder}" />
		<table id="orderDishTable">
			<tr>
				<td>
					订单号:<span data-bind="text:order.id"></span><br>
					
					收货人姓名:<span class="show_and_hid">
						<div class="displayline" data-bind="text:order.custName"></div>
						<input type="text" data-bind="value:order.custName"/></span><br>
						
					下订时间:<span data-bind="text:orderDate"></span><br>
					
					收货人地址:<span class="show_and_hid">
						<div class="displayline" data-bind="text:order.address"></div>
						<input type="text" data-bind="value:order.address"/>
					</span><br>
						
					收货人电话:<span class="show_and_hid">
						<div class="displayline" data-bind="text:order.phone"></div>
						<input type="text" data-bind="value:order.phone"/>
					</span><br>
						
					订单总额:<span data-bind="text:total"></span>元<br>
				</td>
			</tr>
			<tr>
				<td>菜式明细</td>
			</tr>
			<tr>
				<td>
					<table>
						<tr>
							<th>生效</th>
							<th>菜式名称</th>
							<th>菜式价钱</th>
							<th>菜式数量</th>
							<th>该项总价</th>
							<th>烹饪要求</th>
						</tr>
						<!-- ko foreach: order.orderDishes -->
						<tr>
							<td><input type="checkbox" data-bind="checked: dishEnabled" /></td>
							<td><span data-bind="text: dish.name"></span></td>
							<td><span data-bind="text: price"></span></td>
							<td class="show_and_hid">
								<div class="displayline_num" data-bind="text: num"></div>
								<input type="text" data-bind="value: num"/>
							</td>
							<td><span data-bind="text: dishSum"></span></td>
							<td class="show_and_hid">
								<div class="displayline" data-bind="text: demand"></div>
								<input type="text" data-bind="value: demand"/>
							</td>
						</tr>
						<!-- /ko -->
					</table>
				</td>
			</tr>
		</table>
	</div>
	<div id="tabs-workflow">
		<form data-bind="submit: getOrderById">
			订单号:<input type="text" data-bind="value: orderId" />
			<input type="submit" value="获取订单" />
		</form>
		<hr />
		<span data-bind="text: orderZhuangtai"></span><br />
		<div>
			<input type="button" value="抽回订单" data-bind="click: orderDraw">
			<input type="button" value="作废订单" data-bind="click: orderCancled">
		</div>
		<div>
			<input type="checkbox" value="making" data-bind="enable: makingEnabled, checked: myStatus, event:{click: clickMaking}">正在制作
			<input type="checkbox" value="out" data-bind="enable: outEnabled, checked: myStatus, event:{click: clickOut}">已经出货
			<input type="checkbox" value="finished" data-bind="enable: finishedEnabled, checked: myStatus, event:{click: clickFinished}">已经签收,流程结束
		</div>
		<input type="button" value="确认更改" data-bind="enable: ensureEnabled, click: ensureStatus">
		<table id="orderFlowTable">
			<tr>
				<td>
					订单号:<span data-bind="text:order.id"></span><br>
					
					收货人姓名:<span data-bind="text:order.custName"></span><br>
						
					下订时间:<span data-bind="text:orderDate"></span><br>
					
					收货人地址:<span data-bind="text:order.address"></span><br>
						
					收货人电话:<span data-bind="text:order.phone"></span><br>
						
					订单总额:<span data-bind="text:total"></span>元<br>
				</td>
			</tr>
			<tr>
				<td>菜式明细</td>
			</tr>
			<tr>
				<td>
					<table>
						<tr>
							<th>生效</th>
							<th>菜式名称</th>
							<th>菜式价钱</th>
							<th>菜式数量</th>
							<th>该项总价</th>
							<th>烹饪要求</th>
						</tr>
						<!-- ko foreach: order.orderDishes -->
						<tr>
							<td><input type="checkbox" data-bind="checked: dishEnabled" /></td>
							<td><span data-bind="text: dish.name"></span></td>
							<td><span data-bind="text: price"></span></td>
							<td><span data-bind="text: num"></span></td>
							<td><span data-bind="text: dishSum"></span></td>
							<td><span data-bind="text: demand"></span></td>
						</tr>
						<!-- /ko -->
					</table>
				</td>
			</tr>
		</table>
	</div>
	<div id="tabs-uncancled">
		<form data-bind="submit: getCancledOrderById">
			订单号:<input type="text" data-bind="value: orderId" />
			<input type="submit" value="获取订单" />
		</form>
		<input type="button" value="查看今天作废的订单" data-bind="click: getCancledOrdersToday">
		<div>状态:<span data-bind="text: status"></span></div>
		<table id="ordercancledtable">
			<tr>
				<th>订单id</th>
				<th>收货人姓名</th>
				<th>下订时间</th>
				<th>收货人电话</th>
				<th>下订总额</th>
				<th>目前状态</th>
				<th>送货地址</th>
				<th>操作</th>
			</tr>
			<tbody data-bind="foreach: {data: orders, as: 'order'}">
				<tr>
					<td><span data-bind="text: order.id"></span></td>
					<td><span data-bind="text: order.custName"></span></td>
					<td><span data-bind="text: $root.orderDate(order.time())"></span></td>
					<td><span data-bind="text: order.phone"></span></td>
					<td><span data-bind="text: order.sum"></span></td>
					<td><span data-bind="text: order.orderStatus"></span></td>
					<td><span data-bind="text: order.address"></span></td>
					<td><input type="button" value="恢复订单" data-bind="visible: order.id()>0,click: function() {$root.uncancledOrder(order)}"/></td>
				</tr>
			</tbody>
		</table>
	</div>
</div>
</body>
</html>